package com.train.mgr.config.secrity.components;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.config.annotation.SecurityConfigurerAdapter;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.web.DefaultSecurityFilterChain;
import org.springframework.stereotype.Component;

@Component
public class TrainAuthenticationSecurityConfig extends SecurityConfigurerAdapter<DefaultSecurityFilterChain, HttpSecurity> {
    
    //处理业务类
    @Autowired
    private UserDetailsServiceImpl userDetailsService;

    @Override
    public void configure(HttpSecurity http) {
       
        TrainAuthenticationProvider provider = new TrainAuthenticationProvider();
        //设置到provider中
        provider.setUserDetailsService(userDetailsService);
        //注册配置
        http.authenticationProvider(provider);
    }
}
